package cnpm02.j2ee.group3.model;

import static cnpm02.j2ee.group3.model.Gender.MALE;

import java.util.Date;
import java.util.Iterator;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;


public class DBMappingTesting {
	public static void main(String... strings) {
		System.out.println("Hello world!");
		try {
			SessionFactory session = HibernateUtils.getSessionFactory();
			Session sess = session.getCurrentSession();
			Transaction tx = sess.beginTransaction();
			
//			Nationality nationality = new Nationality();
//			nationality.setCode("VIN");
//			NationalityTranslation viNt = new NationalityTranslation(nationality,
//					SupportedLanguage.VI, "Việt Nam");
//			NationalityTranslation enNt = new NationalityTranslation(nationality,
//					SupportedLanguage.EN, "Viet Nam");
//			
//			Language lang = new Language();
//			lang.setCode("TVI");
//			LanguageTranslation viLt = new LanguageTranslation(lang,
//					SupportedLanguage.VI, "Tiếng Việt");
//			LanguageTranslation enLt = new LanguageTranslation(lang,
//					SupportedLanguage.EN, "VietNamese");
//			
//			SecretQuestion ques = new SecretQuestion();
//			ques.setCode("QUE1");
//			SecretQuestionTranslation viSqt = new SecretQuestionTranslation(ques,
//					SupportedLanguage.VI, "Cô giáo đầu tiên của bạn tên gì?");
//			SecretQuestionTranslation enSqt = new SecretQuestionTranslation(ques,
//					SupportedLanguage.EN, "What is the name of your first teacher?");
//			PhoneNumber phoneNo = new PhoneNumber("84", "0946967033");
//			
//			Person person = new Person("Binh", "Tran Van", new Date(), MALE,
//					nationality, lang, ques, "Cô Phượng", phoneNo,
//					"binh12121989@gmail.com", "binhvt", "binh", true, true);
//			sess.persist(person);
//			
//			Iterator<Person> iter = sess.createQuery("from Person").iterate();
//			while(iter.hasNext()) {
//				Person per = iter.next();
//				System.out.println(per.getPhoneNumber());
//			}
//			tx.commit();
			System.out.println("omg it is successfull");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Failed!");
		}
	}
}
